package com.isnmp.common.snmp.impl;

import org.snmp4j.PDU;
import org.snmp4j.Snmp;
import org.snmp4j.Target;
import org.snmp4j.event.ResponseEvent;
import org.snmp4j.smi.OID;
import org.snmp4j.smi.Variable;
import org.snmp4j.smi.VariableBinding;

import com.isnmp.common.base.MyException;
import com.isnmp.common.snmp.SNMPAPI;

public class GetNextOIDValueAction {
    public static Variable getNextValue(String paramString, Snmp paramSnmp, Target paramTarget) throws MyException {
        Object localObject;
        try {
            PDU localPDU1 = new PDU();
            localPDU1.add(new VariableBinding(new OID(paramString)));
            localObject = paramSnmp.getNext(localPDU1, paramTarget);
            SNMPUtils.checkSNMPErro((ResponseEvent) localObject);
            PDU localPDU2 = ((ResponseEvent) localObject).getResponse();
            VariableBinding localVariableBinding = localPDU2.get(0);
            Variable localVariable = localVariableBinding.getVariable();
            String str = localVariable.toString();
            if ((str.equalsIgnoreCase("noSuchInstance")) || (str.equalsIgnoreCase("No such name")) || (str.equalsIgnoreCase("noSuchObject")))
                throw new MyException(SNMPAPI.MessageNoSuchOID);
            return localVariable;
        } catch (Exception localException) {
            localObject = Messages.getString("GetNextOIDValueAction.3") + paramString + Messages.getString("GetNextOIDValueAction.4") + localException.getMessage();
        }
        throw new MyException((String) localObject);
    }

    public static void main(String[] paramArrayOfString) {
        new GetOIDValueAction();
    }
}